// ActionScript file



import spark.filters.ColorMatrixFilter;

public var matrixCol:Array = [
	-1, -1, -1, 0, 0,
	-1, -1, -1, 0, 0,
	-1, -1, -1, 0, 0,
	 0,  0,  0, 1, 0];

public var dictionary_Contrast_pos=[
	1,1.06,1.12,1.18,1.25,1.34,1.44,1.56,1.71,1.86,2,2.3,2.6,2.9,
	3.37,4,5,6.5,8.3,9.7,11];

public var dictionary_Contrast_neg = [
0.95,0.9,0.85,0.8,0.75,0.7,0.65,0.6,0.55,0.50,0.45,0.4,0.35,0.30,0.25,0.20,0.15,0.10,0.05,0.00];


public var contrast_offset_pos=[3.81,7.62,11.43,15.875,21.59,27.94,35.56,45.085,54.61,
	63.5,82.55,	101.6,120.65,150.495,190.5,254,349.25,463.55,
	552.45,635
];

public var contrast_offset_neg = [3.175,6.35,9.525,12.7,15.875,19.05,22.225,25.4,
	28.575,31.75,34.925,38.1,41.275,44.45,47.625,50.8,53.975,57.15,
	60.3,63.5];


public function toGray()
{
	var greyScale = new Array();
	greyScale = matrixCol;
	greyScale[0]=0.33;greyScale[1]=0.33;greyScale[2]=0.33;
	greyScale[5]=0.33;greyScale[6]=0.33;greyScale[7]=0.33;
	greyScale[10]=0.33;greyScale[11]=0.33;greyScale[12]=0.33;
	//trace(greyScale);
	//greyScale = [0.33,0.33,0.33,0,0,0.33,0.33,0.33,0,0,0.33,0.33,0.33,0,0,0,0,0,1,0];
	//trace(greyScale);
	var colorMatrix = new ColorMatrixFilter();
	colorMatrix.matrix = greyScale;
	return [colorMatrix];
}

public function applyContrast(value=false)
{
	var contrast = new Array();
	contrast = matrixCol;
	if(value)
		{
			
			contrast = [2,0,0,0,value,0,2,0,0,value,0,0,2,0,value,0,0,0,1,0]}
	contrast = [2,0,0,0,-63.5,0,2,0,0,-63.5,0,0,2,0,-63.5,0,0,0,1,0];
	var colorMatrix:ColorMatrixFilter = new ColorMatrixFilter();
	colorMatrix.matrix = contrast;
	return [colorMatrix];
}

public function applySaturation()
{
	var saturation = new Array();
	saturation = matrixCol;
	saturation = [2.86678,-1.64538,-0.2214,0,0,-0.83322,2.05462,-0.2214,0,0,-0.83322,-1.64538,3.4786,0,0,0,0,0,1,0];
	var colorMatrix:ColorMatrixFilter = new ColorMatrixFilter();
	colorMatrix.matrix = saturation;
	return [saturation];
}

public function brightness(offset=false)
{
	var brightness = new Array();
	brightness = matrixCol;
	if(offset)
		brightness = [1,0,0,0,offset,0,1,0,0,offset,0,0,1,0,offset,0,0,0,1,0];
	else
		brightness = [1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];
	var colorMatrix:ColorMatrixFilter = new ColorMatrixFilter();
	colorMatrix.matrix = brightness;
	return colorMatrix;
}



//EOF